﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace project
{
    public partial class SupplierAdd : Form
    {
        private SupplierManage supplierManage;
        public SupplierAdd(SupplierManage supplierManages)
        {

            InitializeComponent();
            this.supplierManage = supplierManages;
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string address = this.textBoxAddress.Text, name = this.textBoxName.Text, phone = this.textBoxPhone.Text, bankId = this.textBoxBankId.Text, email = this.textBoxEmail.Text, contact = this.textBoxContact.Text;
            string sql = "INSERT INTO [dbo].[Supplier]([SupplierName],[Phone] ,[Email],[Contact],[BankId],[Address])VALUES('{0}','{1}','{2}','{3}','{4}','{5}')";
            sql = string.Format(sql,name,phone,email,contact,bankId,address);
            int re= DBHelper.ExecuteNonQuery(sql);
            if (re>0)
            {
                MessageBox.Show("添加成功");
                supplierManage.InitData();
                this.Close();
            }

        }
    }
}
